const app = getApp();
const request = require('../../api/request');
Page({
  data: { member: null },
  onLoad(options) {
    const id = options.id;
    const imgBase = app.globalData.imgBase || 'http://192.168.235.111:8080';
    request.get(`/members/${id}`).then(res => {
      // 拼接完整图片地址
      if (res.photo && !/^https?:/.test(res.photo)) {
        res.photo = imgBase + res.photo;
      }
      this.setData({ member: res });
    });
  },
  previewPhoto() {
    const url = this.data.member && this.data.member.photo;
    if (url) {
      wx.previewImage({
        urls: [url],
        current: url
      });
    }
  }
}); 